<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>隔行变色</title>
    <script src="js/jquery-1.12.4.js"></script>
</head>
<body>
    <table border="1" cellspacing="0" cellpadding="5" bordercolor="red">
        <tr>
            <td>id</td>
            <td>姓名</td>
            <td>性别</td>
            <td>年龄</td>
        </tr>
        <tr>
            <td>1</td>
            <td>郭松航</td>
            <td>男</td>
            <td>18</td>
        </tr>
        <tr>
            <td>2</td>
            <td>周睿</td>
            <td>男</td>
            <td>18</td>
        </tr>
        <tr>
            <td>3</td>
            <td>王持方</td>
            <td>男</td>
            <td>18</td>
        </tr>
        <tr>
            <td>4</td>
            <td>王辰</td>
            <td>男</td>
            <td>18</td>
        </tr>
        <tr>
            <td>5</td>
            <td>李欢</td>
            <td>男</td>
            <td>18</td>
        </tr>
    </table>
</body>
<script>
            $(function () {
                $("tr:even").css("background-color", "yellow");
                $("tr:odd").css("background-color", "gray");
                $("tr:first").css("background-color", "green");
            });
</script>
</html>